<template>
  <div class="add_production_box">
    <el-dialog
      @close="handleClose(false)"
      @open="handleOpen"
      close-on-press-escape
      v-dialogDrag
      :title="'合炉'"
      :close-on-click-modal="false"
      :lock-scroll="false"
      :visible="showDialog"
      width="50%"
    >
      <el-table
        :span-method="objectSpanMethod"
        border
        size="mini"
        :data="list"
        style="width: 100%; margin-bottom: 14px"
      >
        <template v-for="(item, index) in getColumnList">
          <el-table-column
            :show-overflow-tooltip="true"
            :key="index"
            :width="item.width"
            :prop="item.prop"
            :label="item.label"
            align="center"
          >
          </el-table-column>
        </template>
        <el-table-column fixed="right" label="是否分配">
          <!-- eslint-disable-next-line -->
          <template slot-scope="scope">
            <el-switch
              v-model="isSetDev"
              :active-value="true"
              :inactive-value="false"
              size="small"
            >
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="设备分配">
          <!-- <template slot-scope="scope">
            <el-cascader
              :disabled="!scope.row.isSetDev"
              :props="defualtProps"
              v-model="scope.row.val"
              :options="devList(scope.row.deviceInfoList)"
              size="small"
              @change="cascaderChange"
            ></el-cascader>
          </template> -->
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="handleClose(false)">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
const COLUMN_LIST = [
  {
    label: "任务号",
    prop: "token",
  },
  {
    label: "班产任务号",
    prop: "productionTaskNumber",
    width: "120px",
  },
  {
    label: "批次号",
    prop: "batchNumber",
  },
  {
    label: "零件号",
    prop: "partNumber",
  },
  {
    label: "零件名称",
    prop: "partName",
  },
  {
    label: "工序号",
    prop: "processNumber",
  },
  {
    label: "工序名称",
    prop: "processName",
  },
  {
    label: "工艺版次",
    prop: "formulaVersion",
  },
  {
    label: "来件数量",
    prop: "partTotalCount",
  },
  {
    label: "状态",
    prop: "state",
  },
];
export default {
  computed: {
    getColumnList() {
      return COLUMN_LIST;
    },
  },
  props: {
    list: {
      type: Array,
      default: () => [],
    },
    showDialog: {
      type: Boolean,
      default: false,
    },
  },

  data() {
    return {
      isSetDev: false,
    };
  },
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 10 || columnIndex === 11) {
        if (rowIndex == 0) {
          return {
            rowspan: this.list.length, //合并多少
            colspan: 1,
          };
        } else {
          // 不需要合并的还原,否则会错位
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
    },
    //弹窗打开执行操作
    handleOpen() {},
    // 弹窗关闭执行操作
    handleClose(isRefresh) {
      this.$emit("update:showDialog", false);
    },
  },
};
</script>

<style lang='scss' scoped>
</style>
